/*
 * Copyright (c) 2010 CCX(China) Co.,Ltd. All Rights Reserved.
 *
 * This software is the confidential and proprietary information of
 * CCX(China) Co.,Ltd. ("Confidential Information").
 * It may not be copied or reproduced in any manner without the express 
 * written permission of CCX(China) Co.,Ltd.
 *
 * @author WUKUNMENG
 * Date: Jul 5, 2010 9:37:04 AM
 */
package com.ccxe.manage.web;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ccxe.manage.service.impl.MenuProcess;

/**
 * @author WUKUNMENG
 *
 */
public class MenuManageServlet extends HttpServlet{

	/**
	 * �˵�����SERVLET
	 */
	private static final long serialVersionUID = -8527112548796873069L;
	private MenuProcess process = new MenuProcess();
	
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		doPost(req, resp);
	}

	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		String opType = req.getParameter("opType");
		if(opType == null) {
			req.setAttribute("rootMenu", process.getRootMenu());
			req.getRequestDispatcher("/jsp/menu/menu.jsp").forward(req, resp);
		} else if(opType.trim().equalsIgnoreCase("0")){ // 0 add_menu
			process.addMenu(req, resp);
		} else if(opType.trim().equalsIgnoreCase("1")) {// 1 update_menu
			process.updateMenu(req, resp);
		} else if(opType.trim().equalsIgnoreCase("2")) {// 2 delete_menu
			process.deleteMenu(req, resp);
		} else if(opType.trim().equalsIgnoreCase("3")) {// 3 show_left
			process.showLeft(req, resp);
		} else if(opType.trim().equalsIgnoreCase("4")) {// 4 show_right
			process.showRight(req, resp);
		} else {
			req.getRequestDispatcher("/jsp/menu/menu.jsp").forward(req, resp);
		}
	}

}
